{extend name="public:layout" /}
{block name="content"}
<div class="page">
  <div class="fixed-bar">
    <div class="item-title"><a class="back" href="{:url('AuthManager/index')}" title="返回列表"><i class="icon iconfont icon-fanhui"></i></a>
      <div class="subject">
        <h3>权限设置 - 编辑权限组“{$this_group.title}”</h3>
        <h5>管理中心操作权限及分组设置</h5>
      </div>
    </div>
  </div>
  <!-- 操作说明 -->
  <div class="explanation" id="explanation">
    <div class="title" id="checkZoom"><i class="icon iconfont icon-dengpao"></i>
      <h4 alt="提示相关设置操作时应注意的要点" class="itip">操作提示</h4>
      <span id="explanationZoom" alt="收起提示" class="itip"></span>
    </div>
    <ul>
      <li>可在标题处全选所有功能或根据功能模块逐一选择操作权限，提交保存后生效。</li>
    </ul>
  </div>
  <form action="{:url('AuthManager/writeGroup')}" name="adminForm" id="add_form" enctype="application/x-www-form-urlencoded" method="POST" class="form-horizontal auth-form" style="margin-bottom: 50px;">
    <div class="ncap-form-all">
      <div class="title">
        <h3>权限操作设置详情</h3>
      </div>
      {volist name="node_list" id="node" }
      <dl class="row">
          <dt class="tit">
               <span><input class="checkbox" type="checkbox" nctype="modulesAll" value="<?php echo $main_rules[$node['url']] ?>" name="rules[]">{$node.title}模块功能</span>
          </dt>
          <dd class="opt nobg nopd nobd nobs">
          {present name="node['child']"}
          {volist name="node['child']" id="child" }
          {present name="child['operator']"}
          {volist name="child['operator']" id="op"}
              <div class="ncap-account-container">
                  <h4><input class="checkbox" type="checkbox" nctype="groupAll" value="<?php echo $auth_rules[$op['url']] ?>" name="rules[]">{$op.title}操作</h4>
                  <ul class="ncap-account-container-list">
                  {present name="op['operator']"}
                  {volist name="op['operator']" id="op"}
                  <li><input class="checkbox" type="checkbox" value="<?php echo $auth_rules[$op['url']] ?>" name="rules[]">{$op.title}</li>
                  {/volist}
                  {/present}
                  </ul>
              </div>
          {/volist}
          {/present}
          {/volist}
          {/present}
          </dd>
      </dl>
      {/volist}
      <input type="hidden" name="id" value="{$this_group.id}" />
      <div class="fix-bot"><a href="JavaScript:void(0);" class="ncap-btn-big ncap-btn-green" onclick="document.adminForm.submit()">确认提交</a></div>
    </div>
  </form>
</div>
<script type="text/javascript" charset="utf-8">
    +function($){
        // 全选
        $('#limitAll').click(function(){
          $('input[type="checkbox"]').attr('checked',$(this).attr('checked') == 'checked');
        });
        // 功能模块
        $('input[nctype="modulesAll"]').click(function(){
            $(this).parents('dt:first').next().find('input[type="checkbox"]').attr('checked',$(this).attr('checked') == 'checked');
        });
        // 功能组
        $('input[nctype="groupAll"]').click(function(){
            $(this).parents('h4:first').next().find('input[type="checkbox"]').attr('checked',$(this).attr('checked') == 'checked');
        });

        var rules = [{$this_group.rules}];
        $('.checkbox').each(function(){
            if( $.inArray( parseInt(this.value,10),rules )>-1 ){
                $(this).prop('checked',true);
            }
            if(this.value==''){
                $(this).closest('span').remove();
            }
        });
    }(jQuery);
</script>
{/block}
